//
//  OACellConfig.h
//  OASDK_Works
//
//  Created by ChenJie on 3/29/20.
//  Copyright © 2020 Mist. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "OACellViewModelProtocol.h"
#import "OALineInset.h"

@class OASectionConfig;
@class OACellConfig;

typedef void (^OACellActionCallback)(OACellConfig *cellConfig);

@interface OACellConfig : NSObject

@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) Class cellClass;
@property (nonatomic, strong) id<OACellViewModelProtocol> cellViewModel;
@property (nonatomic, assign) CGFloat staticHeight;
@property (nonatomic, copy) OACellActionCallback cellDidSelect;
@property (nonatomic, assign) UITableViewCellSelectionStyle cellSelectionStyle;

/* separator */
@property (nonatomic, assign) OALineInset topSeparator;
@property (nonatomic, assign) OALineInset bottomSeparator;
@property (nonatomic, strong) UIColor *topSeparatorColor;
@property (nonatomic, strong) UIColor *bottomSeparatorColor;

/* section */
@property (nonatomic, strong, readonly) OASectionConfig *sectionConfig;
@property (nonatomic, copy) OASectionConfig * (^sectionOfCell)(void);

/* indexPath */
@property (nonatomic, strong, readonly) NSIndexPath *indexPath;
@property (nonatomic, copy) NSIndexPath * (^indexPathOfCell)(OACellConfig *cellConfig);

/* init */
+ (instancetype)cellWithType:(NSString *)cellType viewModel:(id)viewModel;
+ (instancetype)cellWithType:(NSString *)cellType staticHeight:(CGFloat)staticHeight viewModel:(id)viewModel;
+ (instancetype)cellWithName:(NSString *)name cellType:(NSString *)cellType viewModel:(id)viewModel;

+ (instancetype)cellWithName:(NSString *)name
                    cellType:(NSString *)cellType
                staticHeight:(CGFloat)staticHeight
                   viewModel:(id)viewModel;

/* add action */
- (void)setAction:(OACellActionCallback)action forEvent:(id)event;

/* update cell */
- (void)updateCell;
- (void)updateCellWithAnimation:(UITableViewRowAnimation)animation;

#pragma mark - Delegate methods

/* UITableViewDataSource */
- (UITableViewCell *)cellForRowWithTableView:(UITableView *)tableView;

/* UITableViewDelegate */
- (CGFloat)heightForRowWithCellWidth:(CGFloat)cellWidth;
- (void)didSelectRow;

@end

